import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 
 */

/**
 * @author IBRAHIMLI NIhat
 * @author BAYRAMOV Matin
 * 
 */
public class Processor {

	public static int all_processor_number = 1;

	private int id;

	private int avaibleTime;

	private Set<Task> tasks;

	public Processor() {
		this.setId(all_processor_number);
		all_processor_number++;
		this.setAvaibleTime(0);
		this.setTasks(new HashSet<Task>());
	}

	/**
	 * 
	 * @param task
	 */
	public void addTask(Task task) {
		this.tasks.add(task);
		this.setAvaibleTime(this.getAvaibleTime() + task.getExecutionTime());
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the tasks
	 */
	public Set<Task> getTasks() {
		return tasks;
	}

	/**
	 * @param hashSet
	 *            the tasks to set
	 */
	public void setTasks(HashSet<Task> hashSet) {
		this.tasks = hashSet;
	}

	/**
	 * @return the avaibleTime
	 */
	public int getAvaibleTime() {
		return avaibleTime;
	}

	/**
	 * @param avaibleTime
	 *            the avaibleTime to set
	 */
	public void setAvaibleTime(int avaibleTime) {
		this.avaibleTime = avaibleTime;
	}
	
	public String toString() {
		String str = "";
		str += "Processor "+this.getId()+" : ";
		for (Task task : this.tasks) {
			str += task.toString() + ", ";
		}
		str += "\n";
		
		return str;
	}

}
